sum of all substrings of a string representing a number